import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { Transform } from "../engine/Transform";
import { number } from "../engine/validators/number";
import { ItemSpeed } from "./ItemSpeed";

export class CharacterWalkable_2 extends Behaviour {
    private currentSpeed = 0;
    @number()
    speed = 5;

    onStart() {
        this.gameObject.onClick = () => {
             console.log(this.gameObject.id);
            // this.gameObject.active=false;
            if (getGameObjectById('Character_2').getBehaviour(ItemSpeed).speed==0) {
                this.currentSpeed = this.speed;
            } else {
                this.currentSpeed = 0;
            }
        };
    }

    onTick(duringTime: number) {
        const transform = getGameObjectById('Character_2').getBehaviour(Transform);
        if(transform.y>=130){
             transform.y -= this.currentSpeed;
        }else{
            transform.y -= 0;
        }
       
    }
}
